package pl.darbat.incomecalc;

import java.util.ArrayList;
import java.util.Collections;

import android.app.Application;
import android.provider.Settings;
import android.util.Log;

import com.bugsense.trace.BugSenseHandler;

public class IncomeApplication extends Application {

	protected static final String TAG = "IncomeApplication";

	@Override
	public final void onCreate() {
		if(IncomeConstants.LOGV) Log.i(TAG, "onCreate");
		super.onCreate();


		ArrayList<String> developerPhones = new ArrayList<String>();
        Collections.addAll(developerPhones, getResources().getStringArray(R.array.developer_phones));
        String deviceId = Settings.Secure.getString(getContentResolver(), Settings.Secure.ANDROID_ID);
        
        if(deviceId == null || !developerPhones.contains(deviceId)) {
        	if(IncomeConstants.LOGV) Log.i(TAG, "Device id: " + deviceId);
        	BugSenseHandler.setup(this, "ffef5e78");
        } else {
        	IncomeConstants.LOGD = true;
        	IncomeConstants.LOGV = true;
        	if(IncomeConstants.LOGV) Log.w(TAG, "Developer phone: " + deviceId);
    		if (IncomeConstants.SUPPORTS_GINGERBREAD) {
    			if(IncomeConstants.LOGV) Log.i(TAG, "Strict Mode Enabled"); 
    			StrictModeWrapper.init();
    		}
        }
	}
}